home *** CD-ROM | disk | FTP | other *** search
- ;BB.Random - Blanker-module for BlitzBlank
- ;Copyright 1993 by Thomas Boerkel
-
- CloseEd
- NoCli
-
- XINCLUDE dosasl.bb2
-
- DEFTYPE.Screen *myscreen
- DEFTYPE.Message *msg,msg2
- DEFTYPE.MsgPort *port,*port2
- DEFTYPE.AnchorPath *ap
- DEFTYPE.l
-
- Dim modname$(100)
- Dim modselect$(100)
-
- Select Par$(1)
- Case "BLANK"
- Gosub readconfig
- name$="BB.BlankModule"+Chr$(0)
- If selected
- Repeat
- m=Rnd(selected)+1
- Until selected=1 OR m<>last
- last=m
- Gosub writeconfig
- dos$="run "+path$+"BB."+modselect$(m)
-
- For i=1 To 8
- dos$+" "+Par$(i)
- Next i
- dos$+" "+path$+Chr$(0)
- Execute_ &dos$,0,0
- Repeat
- Delay_ 5
- Forbid_
- *port2=FindPort_(&name$)
- Permit_
- cp+1
- Until cp=40 OR *port2
- If *port2
- *port=CreateMsgPort_()
- *port\mp_Node\ln_Name=&name$
- *port\mp_Node\ln_Pri=2
- AddPort_ *port
- EndIf
- EndIf
- If *port2
- Repeat
- WaitPort_ *port
- *msg=GetMsg_(*port)
- Until *msg
- RemPort_ *port
- DeleteMsgPort_ *port
- EndIf
- Delay_ 10
- Forbid_
- *port=FindPort_(&name$)
- Permit_
- If *port
- msg2\mn_Length=SizeOf.Message
- PutMsg_ *port,msg2
- EndIf
- Delay_ 250
- Case "INFO"
- title$="Random"+Chr$(0)
- reqtext$="Random - Module for BlitzBlank"+Chr$(10)
- reqtext$+Chr$(169)+" 1993 by Thomas Brkel"+Chr$(10)+Chr$(10)
- reqtext$+"Other modules will be randomly started."+Chr$(10)+Chr$(10)
- reqtext$+"Choose which modules to start in the config-window."+Chr$(0)
- gadget$="OK"+Chr$(0)
- easy.EasyStruct\es_StructSize=SizeOf.EasyStruct
- easy\es_Title=&title$
- easy\es_TextFormat=&reqtext$
- easy\es_GadgetFormat=&gadget$
- EasyRequestArgs_ 0,easy,0,0
- Case "CONFIG"
-
- *myscreen=LockPubScreen_(0)
- width=*myscreen\Width
- height=*myscreen\Height
- font=*myscreen\Font\ta_YSize
- Gosub readconfig
- Gosub findmodules
- WbToScreen 0
- BorderPens 2,1
- sp=Int(modules/10)
- For x=0 To sp
- For y=1 To 10
- If x*10+y<=modules
- TextGadget 0,x*140+20,y*13+10,1,x*10+y,LSet$(modname$(x*10+y),15)
- For j=1 To selected
- If modname$(x*10+y)=modselect$(j)
- Toggle 0,x*10+y,On
- EndIf
- Next j
- EndIf
- Next y
- Next x
- ww=sp*140+170
- Window 0,width/2-ww/2,height/2-80,ww,160,$100e,"Random",1,2,0
- Repeat
- ev=WaitEvent
- Until ev=$200
- selected=0
- For i=1 To modules
- If GadgetStatus(0,i)
- selected+1
- modselect$(selected)=modname$(i)
- EndIf
- Next i
- Free Window 0
- Gosub writeconfig
- UnlockPubScreen_ 0,*myscreen
- End Select
-
- End
-
- .readconfig
- path$=Par$(9)
- For i=10 To NumPars
- path$=path$+" "+Par$(i)
- Next i
- If ReadFile(0,path$+"BB.Modules.config")
- FileInput 0
- While NOT Eof(0)
- If Edit$(100)="*** Random ***"
- selected=Val(Edit$(5))
- last=Val(Edit$(5))
- For i=1 To selected
- modselect$(i)=Edit$(30)
- Next i
- EndIf
- Wend
- DefaultInput
- CloseFile 0
- EndIf
- Return
-
-
- .writeconfig
- If ReadFile(0,path$+"BB.Modules.config")
- If WriteFile(1,path$+"BB.Modules.temp")
- FileInput 0
- FileOutput 1
- While NOT Eof(0)
- f$=Edit$(100)
- If f$="*** Random ***"
- Repeat
- f2$=Edit$(100)
- Until Eof(0) OR Left$(f2$,3)="***"
- If NOT Eof(0) Then NPrint f2$
- Else
- NPrint f$
- EndIf
- Wend
- CloseFile 1
- EndIf
- CloseFile 0
- EndIf
- KillFile path$+"BB.Modules.config"
- f$=path$+"BB.Modules.temp"+Chr$(0)
- f2$=path$+"BB.Modules.config"+Chr$(0)
- Rename_ &f$,&f2$
- If OpenFile(0,path$+"BB.Modules.config")
- FileOutput 0
- FileSeek 0,Lof(0)
- NPrint "*** Random ***"
- NPrint selected
- NPrint last
- For i=1 To selected
- NPrint modselect$(i)
- Next i
- CloseFile 0
- EndIf
- Return
-
- .findmodules
- modules=0
- modpattern$="BB."+Chr$(126)+"((#(#?.#?))|Random)"+Chr$(0)
- *ap=AllocMem_(SizeOf.AnchorPath,#MEMF_CLEAR)
- d$=path$+Chr$(0)
- l=Lock_(&d$,-2)
- old=CurrentDir_(l)
- If MatchFirst_(&modpattern$,*ap)=0
- If *ap\ap_Info\fib_DirEntryType<0
- modules+1
- modname$(modules)=UnRight$(Peek$(*ap\ap_Info+8),3)
- EndIf
- While MatchNext_(*ap)=0
- If *ap\ap_Info\fib_DirEntryType<0
- modules+1
- modname$(modules)=UnRight$(Peek$(*ap\ap_Info+8),3)
- EndIf
- Wend
- EndIf
- MatchEnd_ *ap
- FreeMem_ *ap,SizeOf.AnchorPath
- CurrentDir_ old
- UnLock_ l
- modname$(0)=Chr$(0)
- For i=modules+1 To 100
- modname$(i)=Chr$(255)
- Next i
- Sort modname$()
- modname$(0)=""
-
- Return
-